home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpuzzles.3 / xpuzzles / xpuzzles-5.3.1 / xhexagons / rngs.c < prev    next >
Text File  |  1996-02-05  |  593b  |  28 lines

  1. /*
  2. Dr. Park's algorithm published in the Oct. '88 ACM 
  3. "Random Number Generators: Good Ones Are Hard To Find"
  4. His version available at ftp://cs.wm.edu/pub/rngs.tar
  5. Present form by many authors.
  6. */
  7.  
  8. static int Seed = 1;       /* This is required to be 32 bits long */
  9.  
  10. /*
  11.  *      Given an integer, this routine initializes the RNG seed.
  12.  */
  13. void SetRNG(s)
  14.   long s;
  15. {
  16.   Seed = (int) s;
  17. }
  18.  
  19. /*
  20.  *      Returns an integer between 0 and 2147483647, inclusive.
  21.  */
  22. long LongRNG()
  23. {
  24.   if ((Seed = Seed % 44488 * 48271 - Seed / 44488 * 3399) < 0)
  25.     Seed += 2147483647;
  26.   return (long) (Seed - 1);
  27. }
  28.